package com.leetcode.string;

public class ReverseTest {
    public static void main(String[] args) {
        int x = -9;
        int reverse = reverse(x);
        System.out.println(reverse);
    }

    public static int reverse(int x) {
        int rev = 0;
        while(x != 0){
            int temp = rev*10 + x %10;
            if((temp/10) != rev){
                return 0;
            }
            rev = temp;
            x= x/10;
        }
        return rev;
    }
}
